<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	
	<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
	<link href="resources/js/selectJs/select2.css" rel="stylesheet"/>
	<script src="resources/js/selectJs/select2.js"></script>
	
	<script type="text/javascript">
		$(document).ready( function() {
			$("#co_id").select2();
		});
		
		function selectAdv() {
			var coId = $("#co_id").val();
			var coName = $("#coname_" + coId ).val();
			alert( "ID : " + coId + "\n" + "회사명 : " + coName );
			$("input[name=co_id]", opener.document ).val( coId );
			$("#coname_lb", opener.document ).val( coName );
			$("input[name=contentsnum]", opener.document ).val("");
			$("#contents_lb", opener.document ).val("");
			$("#selectAdBtn", opener.document ).attr( "disabled", false );
			self.close();
		}
	</script>
	
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<%
request.setCharacterEncoding( "UTF-8" );
response.setCharacterEncoding( "UTF-8" );
response.setContentType( "text/html; charset=UTF-8" );
%>

<title>꽁알 Administrator</title>
</head>
<body>

	<table align="center" cellpadding="10">
		<tr>
			<td align="center" colspan="2">광고주 선택</td>
		</tr>
		<tr>
			<td align="center">
				<select id="co_id" style="width:180px;">
					<c:forEach var="list" items="${advList }">
						<option value="${list.id }">${list.coname }</option>
					</c:forEach>
				</select>
				
				<c:forEach var="list" items="${advList }">
					<input type="hidden" id="coname_${list.id }" value="${list.coname }"/>
				</c:forEach>
			</td>
			
			<td align="center">
				<input type="button" value="확인" style="width:80px;height:30px;" onclick="selectAdv()"/>
			</td>
		</tr>
	</table>

</body>
</html>